from app import create_app
from app import db as _db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from flask_script.commands import ShowUrls
import logging



app = create_app('default')
manager = Manager(app)

logging.basicConfig(level=logging.DEBUG,                            #控制台打印的日志级别
                    filename='log_new.log',                         # 将日志写入log_new.log文件中
                    filemode='a',                                   #模式，有w和a，w就是写模式，每次都会重新写日志，覆盖之前的日志
                                                                    #a是追加模式，默认如果不写的话，就是追加模式
                    format=
                    '%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'  #日志格式
                    )

migrate = Migrate(app, _db)
manager.add_command('db', MigrateCommand)
manager.add_command("showurls", ShowUrls())


if __name__ == '__main__':
    manager.run()
